classmate = ('huhx', 'linux', 'tomhu')
print(classmate[1], classmate.index('linux'))  # linux
friend = 'huhx'
if friend in classmate:
    print(classmate.index(friend))  # 0

# print(classmate.index('hu'), 'huhx') # ValueError: tuple.index(x): x not in tuple


t = (1) # 这里定义和t=1是一样的。()被认为是小括号
print(t + 45) # 46
t = (1,) # 这是定义一个元素的正确写法
print(t[0]) # 1

dataMap = {'name': 'huhx', 'password': '123456', 8: 8} # map的创建
# print(dataMap['username']) # KeyError: 'username'
if 'name' in dataMap:
    print(dataMap['name']) # huhx
print(dataMap.get('username', 'linux')) # linux
for key in dataMap:
    print('key = %s, and value = %s' % (key, dataMap.get(key)))
for key, item in dataMap.items():
    print(key, item)

dataMap['name'] = 'liuling' # modify
dataMap['age'] = 34 # add


del dataMap['name'] # 删除key=name的元素
dataMap.clear() # 删除dataMap中所有的元素
del dataMap # 删除dataMap
dataMap.pop('name') # 删除并返回key=name的value值


print(dataMap.pop('age'))
# print(dataMap.pop('username')) # KeyError: 'username'

